﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="browsePage.aspx.cs" Inherits="LibrarySystem.WebForm1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="mainContent" runat="server">
    <div id="browseLinks" runat="server">
        <asp:LinkButton ID="browseBooksLink" runat="server" OnClick="browseBooksLink_Click">Böcker</asp:LinkButton> 
        <div class="divider"></div>
        <asp:LinkButton ID="browseAuthorLink" runat="server" OnClick="browseAuthorLink_Click">Författare</asp:LinkButton>
    </div>

<%--ListView and DataPager for BOOKS--%>
    <asp:Panel ID="listBook" runat="server" Visible="true">
        <asp:DataPager ID="DataPager1" runat="server" PagedControlID="bookListView" OnPreRender="DataPager_PreRenderBook">
            <Fields>
            <asp:NextPreviousPagerField ButtonType="Link" LastPageText="<<" PreviousPageText="<" ShowPreviousPageButton="True" FirstPageText="&lt;&lt;" ShowFirstPageButton="True" ShowNextPageButton="False" />
                 <asp:NumericPagerField ButtonType="Link" ButtonCount="10" /> 
                <asp:NextPreviousPagerField ButtonType="Link" FirstPageText="" NextPageText=">" ShowNextPageButton="True" LastPageText="&gt;&gt;" ShowLastPageButton="True" ShowPreviousPageButton="False" />            
                </Fields>
      </asp:DataPager>
    
        <asp:ListView ID="bookListView" runat="server" OnDataBound="bookListView_DataBound">
            <LayoutTemplate> 
                 <tbody> <asp:PlaceHolder runat="server" ID="itemPlaceholder" /> </tbody>
            </LayoutTemplate>
            <ItemTemplate>
                <asp:LinkButton  runat="server" OnCommand="listItem_ClickedBook" CommandName='<%#Eval("ISBN")%>'>
                    <table id="bookTable"> <tr><td id="bookTitle"><%# Eval("Title") %></td></tr> <tr><td id="bookAuthor"><%# Eval("Author") %></td></tr> <tr><td id="bookISBN">ISBN: <%# Eval("ISBN") %></td></tr></table>
                </asp:LinkButton>
                </ItemTemplate>
        </asp:ListView>
    
     
      <asp:DataPager ID="DataPager2" runat="server" PagedControlID="bookListView" OnPreRender="DataPager_PreRenderBook" >
            <Fields>
            <asp:NextPreviousPagerField ButtonType="Link" LastPageText="<<" PreviousPageText="<" ShowPreviousPageButton="True" FirstPageText="&lt;&lt;" ShowFirstPageButton="True" ShowNextPageButton="False" />
                 <asp:NumericPagerField ButtonType="Link" ButtonCount="10" /> 
                <asp:NextPreviousPagerField ButtonType="Link" FirstPageText="" NextPageText=">" ShowNextPageButton="True" LastPageText="&gt;&gt;" ShowLastPageButton="True" ShowPreviousPageButton="False" />            
                </Fields>
      </asp:DataPager>
   </asp:Panel>

<%--ListView and DataPager for AUTHORS--%>
    <asp:Panel ID="listAuthor" runat="server" Visible="false">
          <asp:DataPager ID="DataPager3" runat="server" PagedControlID="authorListView" OnPreRender="DataPager_PreRenderAuthor" PageSize="20">
                <Fields>
                <asp:NextPreviousPagerField ButtonType="Link" LastPageText="<<" PreviousPageText="<" ShowPreviousPageButton="True" FirstPageText="&lt;&lt;" ShowFirstPageButton="True" ShowNextPageButton="False" />
                     <asp:NumericPagerField ButtonType="Link" ButtonCount="10" /> 
                    <asp:NextPreviousPagerField ButtonType="Link" FirstPageText="" NextPageText=">" ShowNextPageButton="True" LastPageText="&gt;&gt;" ShowLastPageButton="True" ShowPreviousPageButton="False" />            
                    </Fields>
          </asp:DataPager>
                
            <asp:ListView ID="authorListView" runat="server" OnDataBound="authorListView_DataBound">
                <LayoutTemplate> 
                     <tbody> <asp:PlaceHolder runat="server" ID="itemPlaceholder" /> </tbody>
                </LayoutTemplate>
                <ItemTemplate>
                    <asp:LinkButton  runat="server" OnCommand="listItem_ClickedAuthor" CommandName='<%#Eval("Aid")%>'>
                        <table id="bookTable"> <tr><td id="authorLastName"><%# Eval("LastName") %>, </td><td id="authorFirstName"><%# Eval("FirstName") %></td><td id="authorBirthYear"><%# ((int)Eval("BirthYear") == 0) ? "" : Eval("BirthYear")%></td></tr></table
                    </asp:LinkButton>
                    </ItemTemplate>
            </asp:ListView>        

      <asp:DataPager ID="DataPager4" runat="server" PagedControlID="authorListView" OnPreRender="DataPager_PreRenderAuthor" PageSize="20">
            <Fields>
            <asp:NextPreviousPagerField ButtonType="Link" LastPageText="<<" PreviousPageText="<" ShowPreviousPageButton="True" FirstPageText="&lt;&lt;" ShowFirstPageButton="True" ShowNextPageButton="False" />
                 <asp:NumericPagerField ButtonType="Link" ButtonCount="10" /> 
                <asp:NextPreviousPagerField ButtonType="Link" FirstPageText="" NextPageText=">" ShowNextPageButton="True" LastPageText="&gt;&gt;" ShowLastPageButton="True" ShowPreviousPageButton="False" />            
                </Fields>
      </asp:DataPager>
    </asp:Panel>

</asp:Content>
